<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-09-02 16:35
 *
 * 项目：rm  -  $  - payWidget.php
 *
 * 作者：liwei 
 */

namespace modules\levpays\widgets\pay;

use Lev;
use lev\base\Widgetv;
use lev\helpers\ModulesHelper;
use modules\levpays\helpers\levpaysSetHelper;
use modules\levpays\levpaysHelper;

!defined('INLEV') && exit('Access Denied LEV');

class payWidget extends Widgetv
{

    public static $pre = '';

    public static function run($goods = [])
    {
        //parent::run($show); // TODO: Change the autogenerated stub

        $htms = '';

        levpaysSetHelper::openWxpay() &&
        $htms .= static::render(0, __DIR__ . '/views/run.php', [
            'goods' => $goods,
        ]);

        ModulesHelper::isInstallModule('alipay') &&
        !ModulesHelper::getModuleFileInfo('alipay')['status'] &&
        $htms .= \modules\levpays\modules\alipay\widgets\pay\payWidget::run($goods);

        ModulesHelper::isInstallModule('baidupay') &&
        !ModulesHelper::getModuleFileInfo('baidupay')['status'] &&
        $htms .= \modules\levpays\modules\baidupay\widgets\payWidget::run($goods);
        return $htms;
    }

    public static function paytypeid() {
        $arr = [];
        levpaysSetHelper::openWxpay() &&
        $arr[0] = '微信支付';

        ModulesHelper::isInstallModule('alipay') &&
        !ModulesHelper::getModuleFileInfo('alipay')['status'] &&
        $arr[1] = '支付宝';

        ModulesHelper::isInstallModule('baidupay') &&
        !ModulesHelper::getModuleFileInfo('baidupay')['status'] &&
        $arr[2] = '百度支付';

        return $arr;
    }
    public static function paytypeidIcon() {
        return [
            0 => '<svg class="icon"><use xlink:href="#fa-wxpay"></use></svg>',
            1 => '<svg class="icon"><use xlink:href="#fa-alipay"></use></svg>',
            2 => '<img src="'.levpaysHelper::assets().'/icon/bdumini.png">',
        ];
    }
}